<?

session_start();
 require_once("../includes/config.in.php"); 
 require_once("../includes/class.mysql.php");
  require_once("../includes/function.in.php");
 $db = New DB();
 	$_SESSION['S_ID']=1;
		 $ch=$_POST[ch]; //???????? ????
		$id_suite=$_POST[id_suite];//???????
		$IDLC=$_POST[IDLC];//?????????????????????
		$answerword=$_POST[answerword];//???????????  ??????
			 $db->connectdb(DB_NAME,DB_USERNAME,DB_PASSWORD);


							$dates=date("Y-m-d");
						//???????????? tb_dotest ????
 								$db->add_db("tb_dotest ",array(
											"date_test"=>" ".$dates." ",
											"id_suite"=>" ".$id_suite." ",
											"s_id "=>"".$_SESSION['S_ID'].""
									));
									//???????????
								$res[topdotest]=$db->select_query("select LMdotest_ID  from tb_dotest  order by LMdotest_ID  desc");
								$arr[topdotest] = $db->fetch($res[topdotest]);
								$LMdotest_ID=$arr[topdotest][LMdotest_ID];//??????????????????????  $LMdotest_ID
					
					//
					//?????????????????
					for ($j=0;$j<count($answerword);$j++){
							$db->add_db("tb_dotestdetailword",array(
											"ID"=>" ".$IDLC[$j]." ",//??????????
											"w_ans"=>" ".$answerword[$j]." ",//?????????????
											"LMdotest_ID"=>"".$LMdotest_ID."" //id ??????????????
						));
					}			
								
							
		//????	??????????		
		for ($i=0;$i<count($ch);$i++){
					$db->add_db("tb_dotestdetail",array(
											"Q_ID"=>" ".$ch[$i]." ",
											"LMdotest_ID"=>"".$LMdotest_ID.""
						));
				
		}
		sleep(2);// ??????????? 2 ??
		echo "<script>window.location='main.php';//</script>";
		
			$ProcessOutput .= "<BR><BR>";
		$ProcessOutput .= "<CENTER><IMG SRC=\"images/login-welcome.gif\" BORDER=\"0\"><BR><BR>";
		$ProcessOutput .= "<FONT COLOR=\"#336600\"><B>????????????????????????????????? </B></FONT><BR><BR>";
		$ProcessOutput .= "</CENTER>";
		$ProcessOutput .= "<BR><BR>";

?>